package com.cuiweiyou.happypaint.view;

import android.content.Context;
import android.content.DialogInterface;

import androidx.appcompat.app.AlertDialog;

public class DialogView {

    public static void showDialog(Context context, OnSureListener listener, String msg, Object obj) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle("确认");
        builder.setMessage(msg);

        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (null != listener) {
                    listener.onSure(obj);
                }
            }
        });

        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (null != listener) {
                    listener.onNo(obj);
                }
            }
        });

        AlertDialog dialog = builder.create();
        dialog.show();

    }

    public interface OnSureListener {
        public void onSure(Object obj);
        public void onNo(Object obj);
    }
}
